//
//  YHStatus.swift
//  YHWeibo
//
//  Created by 昱含 on 16/5/24.
//  Copyright © 2016年 YuHan. All rights reserved.
//

import UIKit

class YHStatus: NSObject {

//    微博创建时间
    var created_at : String?
//    微博ID
    var id : Int64 = 0
//    微博信息内容
    var text : String?
//    微博来源
    var source : String?
//    微博作者的用户信息字段 详细
    var user : YHUser?
    
    var retweeted_status : YHStatus?
    
    var pic_urls: [YHPicture]?
    
    //转发的数量
    var reposts_count: Int = 0
    //评论
    var comments_count: Int = 0
    //赞
    var attitudes_count: Int = 0

    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let dict = value as? [String : AnyObject] {
                
                user = YHUser(dict: dict)
            }
            return
        }
        
        if key == "retweeted_status" {
            
            if let dict = value as? [String : AnyObject]{
                
                retweeted_status = YHStatus(dict: dict)
                
//                print(retweeted_status)
            }
            
            return
        }
        
        if key == "pic_urls" {
            
            if let array = value as? [[String : AnyObject]]  {
                
                var temparray = [YHPicture]()
                for item in array {
                    
                    let p = YHPicture(dict: item)
                    
                    temparray.append(p)
                    
                }
                pic_urls = temparray
               
            }
            return
        }
        
        super.setValue(value, forKey: key)

        
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {  }
}